<?php
require '../config.php';
require '../libs/class.login.php';

$username = isset($_POST['username']) ? strval($_POST['username']) : NULL;
$password = isset($_POST['password']) ? strval($_POST['password']) : NULL;
$action = isset($_POST['action']) ? strval($_POST['action']) : NULL;

if ($action == 'login') {
	$log = new logmein();
	$log->encrypt = true;

	$status = $log->login($username, $password);

	if ($status) {
		header("HTTP/1.1 301 Moved Permanently");
		header('Location: /admin/?mod=games');
		exit();
	} else {
		header("HTTP/1.1 301 Moved Permanently");
		header('Location: /admin/login.html');
		exit();
	}
} else {
	header("HTTP/1.1 301 Moved Permanently");
	header('Location: /admin/login.html');
	exit();
}